package com.db.blog.menu;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import java.sql.*;

public class MenuadManager extends SqlMapClientDaoSupport implements Menuad {

	public int CountSelect(MenuadVO vo) throws SQLException {
		return (Integer) getSqlMapClientTemplate().queryForObject(
				"CountSelect", vo);
	}

	public void UpUpdate(MenuadVO vo) throws SQLException {

		MenuadVO result = new MenuadVO();
		result.setIdtype(vo.getIdtype());
		result.setOrderno(vo.getOrderno());

		vo.setOno((Integer) getSqlMapClientTemplate().queryForObject(
				"onoSelect", vo));
		result.setOrderno(result.getOrderno() + 1);// orderno=3
		result.setOno((Integer) getSqlMapClientTemplate().queryForObject(
				"onoSelect", result));

		getSqlMapClientTemplate().update("DownUpdate", result);
		getSqlMapClientTemplate().update("UpUpdate", vo);
	}

	public void DownUpdate(MenuadVO vo) throws SQLException {
		MenuadVO result = new MenuadVO();
		result.setIdtype(vo.getIdtype());
		result.setOrderno(vo.getOrderno());

		result.setOrderno(result.getOrderno() - 1);
		result.setOno((Integer) getSqlMapClientTemplate().queryForObject(
				"onoSelect", result));
		vo.setOno((Integer) getSqlMapClientTemplate().queryForObject(
				"onoSelect", vo));
		getSqlMapClientTemplate().update("UpUpdate", result);
		getSqlMapClientTemplate().update("DownUpdate", vo);
	}
}
